Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SlangConfig.cmake with slang build targets #5674

Merged
merged 8 commits into from
Dec 3, 2024

Conversation

ov-l
Copy link

@ov-l ov-l commented Nov 25, 2024

Closes #5649

@ov-l ov-l requested a review from a team as a code owner November 25, 2024 19:24
@CLAassistant
Copy link

CLAassistant commented Nov 25, 2024

CLA assistant check
All committers have signed the CLA.

@jkwak-work jkwak-work added the pr: non-breaking PRs without breaking changes label Nov 26, 2024
@ov-l
Copy link
Author

ov-l commented Nov 26, 2024

I need to reformat the CMakeLists file.

@obhi-d
Copy link
Contributor

obhi-d commented Nov 26, 2024

I am not able to make the wasm build work, so probably I need to skip adding slang as target. I tried to add through this macro:

macro(export_slang_targets)
  set(SlangExportTargetList)
  foreach(target IN ITEMS ${ARGN})
    message(STATUS "----------------> ADDING TARGET ${target}")
    if(TARGET ${target})
      list(APPEND SlangExportTargetList ${target})
    endif()
  endforeach()
  
  if (SlangExportTargetList)
  
    install(TARGETS ${SlangExportTargetList} EXPORT SlangExportTarget)
    
    install(
        EXPORT SlangExportTarget
        FILE ${PROJECT_NAME}Targets.cmake
        NAMESPACE ${PROJECT_NAME}::
        DESTINATION cmake
    )
    
    install(
        FILES
            "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
            "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
        DESTINATION cmake
    )
  
  endif()
endmacro()

# 
export_slang_targets(
  core
  prelude
  unordered_dense
  compiler-core
  slang-capability-defs
  slang-capability-lookup
  slang-reflect-headers
  slang-lookup-tables
  SPIRV-Headers
  slang-common-objects
  slang
)

But other issues crop up if I do so, notably : Target "slang-reflect-headers" INTERFACE_INCLUDE_DIRECTORIES property
contains path: , which is prefixed in the build directory.

Exporting all targets specified in SlangTargets is also not an option because it seems SlangTargets include every target declared within the library and they should not be linked to (for ex. executable targets).

For my use-case, only single slang target works for both Linux and Windows. Probably this needs to be handled correctly instead of how I am doing.

@eliemichel
Copy link
Contributor

It might be ok to just not try to find a prebuilt version of Slang when cross-compiling with emscripten (i.e., enclose the find_package within a if (NOT EMSCRIPTEN) and fallback to "manually" locating slangc executable in that case (because I suppose that's all what is needed when the target is WebAssembly -- unless one wants to link slang library into a WebAssembly module but there is no precompiled release for WebAssembly anyways, so one would build from scratch in that case).

@obhi-d
Copy link
Contributor

obhi-d commented Nov 27, 2024

It might be ok to just not try to find a prebuilt version of Slang when cross-compiling with emscripten (i.e., enclose the find_package within a if (NOT EMSCRIPTEN) and fallback to "manually" locating slangc executable in that case (because I suppose that's all what is needed when the target is WebAssembly -- unless one wants to link slang library into a WebAssembly module but there is no precompiled release for WebAssembly anyways, so one would build from scratch in that case).

Yes, I missed your point earlier. I will try that. Thanks for clarifying.

Copy link
Collaborator

@expipiplus1 expipiplus1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to add some documentation to the new code explaining what's going on please. And could you add some documentation to docs/building.md explaining how the config cmake files can be used from an installed slang.

Thanks also! this looks like a good addition!

@obhi-d
Copy link
Contributor

obhi-d commented Nov 30, 2024

Yes, I will add some comments and add docs.

@csyonghe
Copy link
Collaborator

csyonghe commented Dec 2, 2024

For webassembly builds, we will produce the slang-wasm.wasm which is a library that contains the wasm binding to the slang library callable from JavaScript. The binding is defined in slang-wasm.cpp.

@csyonghe
Copy link
Collaborator

csyonghe commented Dec 2, 2024

And we should update the CI setup to include prebuilt binaries for web assembly in our releases.

Once we have proper web assembly release, the playground should be updated to use these releases instead of build from top of tree slang.

@csyonghe
Copy link
Collaborator

csyonghe commented Dec 2, 2024

@expipiplus1 Is this change good to merge?

Copy link
Collaborator

@expipiplus1 expipiplus1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@csyonghe csyonghe enabled auto-merge (squash) December 3, 2024 17:29
@csyonghe csyonghe merged commit 5d8cf47 into shader-slang:master Dec 3, 2024
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: non-breaking PRs without breaking changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide SlangConfig.cmake in releases
7 participants